<!DOCTYPE html>
<html lang="zh-CN">
<head>
  <meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=2">
<meta name="theme-color" content="#222">
<meta name="generator" content="Hexo 5.2.0">
  <link rel="apple-touch-icon" sizes="180x180" href="/images/apple-touch-icon-next.png">
  <link rel="icon" type="image/png" sizes="32x32" href="/images/favicon-32x32-next.png">
  <link rel="icon" type="image/png" sizes="16x16" href="/images/favicon-16x16-next.png">
  <link rel="mask-icon" href="/images/logo.svg" color="#222">

<link rel="stylesheet" href="/css/main.css">


<link rel="stylesheet" href="/lib/font-awesome/css/all.min.css">
  <link rel="stylesheet" href="/lib/pace/pace-theme-minimal.min.css">
  <script src="/lib/pace/pace.min.js"></script>

<script id="hexo-configurations">
    var NexT = window.NexT || {};
    var CONFIG = {"hostname":"sekla.cn","root":"/","scheme":"Muse","version":"7.8.0","exturl":false,"sidebar":{"position":"right","display":"post","padding":18,"offset":12,"onmobile":false},"copycode":{"enable":false,"show_result":false,"style":null},"back2top":{"enable":true,"sidebar":false,"scrollpercent":false},"bookmark":{"enable":false,"color":"#222","save":"auto"},"fancybox":false,"mediumzoom":false,"lazyload":false,"pangu":false,"comments":{"style":"tabs","active":"valine","storage":true,"lazyload":false,"nav":null},"algolia":{"hits":{"per_page":10},"labels":{"input_placeholder":"Search for Posts","hits_empty":"We didn't find any results for the search: ${query}","hits_stats":"${hits} results found in ${time} ms"}},"localsearch":{"enable":false,"trigger":"auto","top_n_per_article":1,"unescape":false,"preload":false},"motion":{"enable":true,"async":false,"transition":{"post_block":"fadeIn","post_header":"slideDownIn","post_body":"slideDownIn","coll_header":"slideLeftIn","sidebar":"slideUpIn"}},"path":"search.xml"};
  </script>

  <meta name="description" content="实验内容 把文件的逻辑结构转换成存储结构。 设计便于顺序存取和直接存取的文件结构。  实验题目1.模拟设计MS-DOS操作系统中磁盘文件的存储结构。当用户对记录式文件采用顺序存以方式时，用户总是依次地访问一个个逻辑记录，即当访问了第i个记录后，下次总是访问第i+1个记录。所以，当用户采用顺序存取方式访问文件时，只要给出访问要求（读或写）而无需再指出要访问的记录号。 采用链接文件结构，只有读出一个物">
<meta property="og:type" content="article">
<meta property="og:title" content="MS-DOS文件储存模拟">
<meta property="og:url" content="http://sekla.cn/2021/12/16/os-schoollab-8/index.html">
<meta property="og:site_name" content="Sekla&#39;s Blog">
<meta property="og:description" content="实验内容 把文件的逻辑结构转换成存储结构。 设计便于顺序存取和直接存取的文件结构。  实验题目1.模拟设计MS-DOS操作系统中磁盘文件的存储结构。当用户对记录式文件采用顺序存以方式时，用户总是依次地访问一个个逻辑记录，即当访问了第i个记录后，下次总是访问第i+1个记录。所以，当用户采用顺序存取方式访问文件时，只要给出访问要求（读或写）而无需再指出要访问的记录号。 采用链接文件结构，只有读出一个物">
<meta property="og:locale" content="zh_CN">
<meta property="og:image" content="https://s2.loli.net/2021/12/15/dWZ42r61nSHAyKM.png">
<meta property="og:image" content="https://s2.loli.net/2021/12/15/QxeBDzd3jIO7naC.png">
<meta property="og:image" content="https://s2.loli.net/2021/12/15/3qSuUxP4WHvMKg5.png">
<meta property="og:image" content="https://s2.loli.net/2021/12/15/KqeUfJx9QjZSur6.png">
<meta property="article:published_time" content="2021-12-16T04:30:00.000Z">
<meta property="article:modified_time" content="2021-12-17T06:22:31.366Z">
<meta property="article:author" content="Sekla">
<meta property="article:tag" content="C++">
<meta name="twitter:card" content="summary">
<meta name="twitter:image" content="https://s2.loli.net/2021/12/15/dWZ42r61nSHAyKM.png">

<link rel="canonical" href="http://sekla.cn/2021/12/16/os-schoollab-8/">


<script id="page-configurations">
  // https://hexo.io/docs/variables.html
  CONFIG.page = {
    sidebar: "",
    isHome : false,
    isPost : true,
    lang   : 'zh-CN'
  };
</script>

  <title>MS-DOS文件储存模拟 | Sekla's Blog</title>
  






  <noscript>
  <style>
  .use-motion .brand,
  .use-motion .menu-item,
  .sidebar-inner,
  .use-motion .post-block,
  .use-motion .pagination,
  .use-motion .comments,
  .use-motion .post-header,
  .use-motion .post-body,
  .use-motion .collection-header { opacity: initial; }

  .use-motion .site-title,
  .use-motion .site-subtitle {
    opacity: initial;
    top: initial;
  }

  .use-motion .logo-line-before i { left: initial; }
  .use-motion .logo-line-after i { right: initial; }
  </style>
</noscript>

  <script type="text/javascript" src="/js/my_js/clicklove.js"></script>
<!-- hexo injector head_end start -->
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/katex@0.12.0/dist/katex.min.css">

<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/hexo-math@4.0.0/dist/style.css">
<!-- hexo injector head_end end --></head>

<body itemscope itemtype="http://schema.org/WebPage">
  <div class="container use-motion">
    <div class="headband"></div>

    <header class="header" itemscope itemtype="http://schema.org/WPHeader">
      <div class="header-inner"><div class="site-brand-container">
  <div class="site-nav-toggle">
    <div class="toggle" aria-label="切换导航栏">
      <span class="toggle-line toggle-line-first"></span>
      <span class="toggle-line toggle-line-middle"></span>
      <span class="toggle-line toggle-line-last"></span>
    </div>
  </div>

  <div class="site-meta">

    <a href="/" class="brand" rel="start">
      <span class="logo-line-before"><i></i></span>
      <h1 class="site-title">Sekla's Blog</h1>
      <span class="logo-line-after"><i></i></span>
    </a>
      <p class="site-subtitle" itemprop="description">Keep Learning Keep Doing</p>
  </div>

  <div class="site-nav-right">
    <div class="toggle popup-trigger">
    </div>
  </div>
</div>




<nav class="site-nav">
  <ul id="menu" class="main-menu menu">
        <li class="menu-item menu-item-home">

    <a href="/" rel="section"><i class="fa fa-home fa-fw"></i>首页</a>

  </li>
        <li class="menu-item menu-item-about">

    <a href="/about/" rel="section"><i class="fa fa-user fa-fw"></i>关于</a>

  </li>
        <li class="menu-item menu-item-tags">

    <a href="/tags/" rel="section"><i class="fa fa-tags fa-fw"></i>标签<span class="badge">14</span></a>

  </li>
        <li class="menu-item menu-item-categories">

    <a href="/categories/" rel="section"><i class="fa fa-th fa-fw"></i>分类<span class="badge">23</span></a>

  </li>
        <li class="menu-item menu-item-archives">

    <a href="/archives/" rel="section"><i class="fa fa-archive fa-fw"></i>归档<span class="badge">100</span></a>

  </li>
  </ul>
</nav>




</div>
    </header>

    
  <div class="back-to-top">
    <i class="fa fa-arrow-up"></i>
    <span>0%</span>
  </div>
  <div class="reading-progress-bar"></div>


    <main class="main">
      <div class="main-inner">
        <div class="content-wrap">
          

          <div class="content post posts-expand">
            

    
  
  
  <article itemscope itemtype="http://schema.org/Article" class="post-block" lang="zh-CN">
    <link itemprop="mainEntityOfPage" href="http://sekla.cn/2021/12/16/os-schoollab-8/">

    <span hidden itemprop="author" itemscope itemtype="http://schema.org/Person">
      <meta itemprop="image" content="/images/avatar.jpg">
      <meta itemprop="name" content="Sekla">
      <meta itemprop="description" content="Sekla">
    </span>

    <span hidden itemprop="publisher" itemscope itemtype="http://schema.org/Organization">
      <meta itemprop="name" content="Sekla's Blog">
    </span>
      <header class="post-header">
        <h1 class="post-title" itemprop="name headline">
          MS-DOS文件储存模拟
        </h1>

        <div class="post-meta">
            <span class="post-meta-item">
              <span class="post-meta-item-icon">
                <i class="far fa-calendar"></i>
              </span>
              <span class="post-meta-item-text">发表于</span>

              <time title="创建时间：2021-12-16 12:30:00" itemprop="dateCreated datePublished" datetime="2021-12-16T12:30:00+08:00">2021-12-16</time>
            </span>
              <span class="post-meta-item">
                <span class="post-meta-item-icon">
                  <i class="far fa-calendar-check"></i>
                </span>
                <span class="post-meta-item-text">更新于</span>
                <time title="修改时间：2021-12-17 14:22:31" itemprop="dateModified" datetime="2021-12-17T14:22:31+08:00">2021-12-17</time>
              </span>
            <span class="post-meta-item">
              <span class="post-meta-item-icon">
                <i class="far fa-folder"></i>
              </span>
              <span class="post-meta-item-text">分类于</span>
                <span itemprop="about" itemscope itemtype="http://schema.org/Thing">
                  <a href="/categories/%E6%93%8D%E4%BD%9C%E7%B3%BB%E7%BB%9F/" itemprop="url" rel="index"><span itemprop="name">操作系统</span></a>
                </span>
            </span>

          
            <span class="post-meta-item" title="阅读次数" id="busuanzi_container_page_pv" style="display: none;">
              <span class="post-meta-item-icon">
                <i class="fa fa-eye"></i>
              </span>
              <span class="post-meta-item-text">阅读次数：</span>
              <span id="busuanzi_value_page_pv"></span>
            </span><br>
            <span class="post-meta-item" title="本文字数">
              <span class="post-meta-item-icon">
                <i class="far fa-file-word"></i>
              </span>
                <span class="post-meta-item-text">本文字数：</span>
              <span>10k</span>
            </span>
            <span class="post-meta-item" title="阅读时长">
              <span class="post-meta-item-icon">
                <i class="far fa-clock"></i>
              </span>
                <span class="post-meta-item-text">阅读时长 &asymp;</span>
              <span>10 分钟</span>
            </span>

        </div>
      </header>

    
    
    
    <div class="post-body" itemprop="articleBody">

      
        <h2 id="实验内容"><a href="#实验内容" class="headerlink" title="实验内容"></a>实验内容</h2><ol>
<li>把文件的逻辑结构转换成存储结构。</li>
<li>设计便于顺序存取和直接存取的文件结构。</li>
</ol>
<h2 id="实验题目"><a href="#实验题目" class="headerlink" title="实验题目"></a>实验题目</h2><h3 id="1-模拟设计MS-DOS操作系统中磁盘文件的存储结构。"><a href="#1-模拟设计MS-DOS操作系统中磁盘文件的存储结构。" class="headerlink" title="1.模拟设计MS-DOS操作系统中磁盘文件的存储结构。"></a>1.模拟设计MS-DOS操作系统中磁盘文件的存储结构。</h3><p>当用户对记录式文件采用顺序存以方式时，用户总是依次地访问一个个逻辑记录，即当访问了第i个记录后，下次总是访问第i+1个记录。所以，当用户采用顺序存取方式访问文件时，只要给出访问要求（读或写）而无需再指出要访问的记录号。</p>
<p>采用链接文件结构，只有读出一个物理块信息后才能从链接字中得知下一个物理块号。所以，当用户要在文件中插入一些信息时，文件系统必须多次地请求启动磁盘读出信息才能做插入工作。</p>
<a id="more"></a>

<p><img src="https://s2.loli.net/2021/12/15/dWZ42r61nSHAyKM.png" alt="image-20211215112256256"></p>
<p>MS-DOS操作系统对链接文件结构作了改进，它是把所有的链接指针集中在一起，存放在文件定位表FAT中。查找链接字时不必读出物理块信息可直接从FAT中得到。</p>
<p>其设计思想是：<br>假定磁盘上共有N个物理块可供使用，FAT就有N项，初始化时为全“0”，表示对应的物理块均可使用，当要存放文件时，从FAT中寻找为“0”的项，其对应的物理块用来存放文件信息，把文件的链接指针（指出物理块号）登记在FAT中，文件第一块块号登记在文件目录中。</p>
<p><img src="https://s2.loli.net/2021/12/15/QxeBDzd3jIO7naC.png" alt="image-20211215112458734"></p>
<p>假定磁盘存储空间共有32个物理块，模拟设计文件定位表FAT。文件定位表可以用一个一维数组<code>FAT[031]</code>来定义，其中一个元素与一个物理块对应。当<code>FAT[i]=0</code>时，表示第i块为空闲块。当<code>FAT[i]=FFF时</code>，表示链接文件到第i块结束。当在0~FFF时，其值指示链接文件中下一个物理块号。</p>
<p>每个物理块只能存放一个逻辑记录，设计一个程序把文件的逻辑结构模拟转换成MS-DOS的链接结构。</p>
<p>要求保 1 1存0 1 0一0 0个1 0已1 0 0经 1 0在1 1主存中的文件时，给出文件名和文件的逻辑记录长度及个数，对一个已经保存的文件，允许用户插入新记录。用键盘输入来模拟用户的要求，输入信息为：“存” 文件名    逻辑记录长度     逻辑记录个数    “插入” 文件名     逻辑记录号</p>
<p><img src="https://s2.loli.net/2021/12/15/3qSuUxP4WHvMKg5.png" alt="image-20211215113440860"></p>
<h3 id="2-模拟便于直接存取的索引文件结构"><a href="#2-模拟便于直接存取的索引文件结构" class="headerlink" title="2.模拟便于直接存取的索引文件结构"></a>2.模拟便于直接存取的索引文件结构</h3><p>索引文件像链接文件一样，文件的逻辑记录信息可存放在非连续的磁盘存储空间中。但这些存放逻辑记录的存储空间不是按链表的形式链接在一起的，而是采用索引表来指出逻辑记录存放的物理位置。<br>  假定把文件中的逻辑记录按次序1，2，3，4，……编号，且约定一个物理块中存放一个逻辑记录。文件中的每一个逻辑记录在索引表中都有一个登记项，登记项指出逻辑记录号以及该记录存放在磁盘上的地址（可用物理块号表示），“最大记录号”表示文件中逻辑记录个数。一个用户建立多个文件时，系统要为每个文件建立一张索引表，索引表的存放地址登记在用户文件目录表中。于是当用户要访问指定文件的某个记录时，系统就能直接查到该记录的物理位置。文件目录与索引表的关系如图：</p>
<p><img src="https://s2.loli.net/2021/12/15/KqeUfJx9QjZSur6.png" alt="image-20211215113650120"></p>
<p>建立索引文件的过程是：寻找一些空闲物理块；逻辑记录存入这些物理块中；把逻辑记录与物理块的对应关系登记在索引表中。</p>
<figure class="highlight cpp"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br><span class="line">35</span><br><span class="line">36</span><br><span class="line">37</span><br><span class="line">38</span><br><span class="line">39</span><br><span class="line">40</span><br><span class="line">41</span><br><span class="line">42</span><br><span class="line">43</span><br><span class="line">44</span><br><span class="line">45</span><br><span class="line">46</span><br><span class="line">47</span><br><span class="line">48</span><br><span class="line">49</span><br><span class="line">50</span><br><span class="line">51</span><br><span class="line">52</span><br><span class="line">53</span><br><span class="line">54</span><br><span class="line">55</span><br><span class="line">56</span><br><span class="line">57</span><br><span class="line">58</span><br><span class="line">59</span><br><span class="line">60</span><br><span class="line">61</span><br><span class="line">62</span><br><span class="line">63</span><br><span class="line">64</span><br><span class="line">65</span><br><span class="line">66</span><br><span class="line">67</span><br><span class="line">68</span><br><span class="line">69</span><br><span class="line">70</span><br><span class="line">71</span><br><span class="line">72</span><br><span class="line">73</span><br><span class="line">74</span><br><span class="line">75</span><br><span class="line">76</span><br><span class="line">77</span><br><span class="line">78</span><br><span class="line">79</span><br><span class="line">80</span><br><span class="line">81</span><br><span class="line">82</span><br><span class="line">83</span><br><span class="line">84</span><br><span class="line">85</span><br><span class="line">86</span><br><span class="line">87</span><br><span class="line">88</span><br><span class="line">89</span><br><span class="line">90</span><br><span class="line">91</span><br><span class="line">92</span><br><span class="line">93</span><br><span class="line">94</span><br><span class="line">95</span><br><span class="line">96</span><br><span class="line">97</span><br><span class="line">98</span><br><span class="line">99</span><br><span class="line">100</span><br><span class="line">101</span><br><span class="line">102</span><br><span class="line">103</span><br><span class="line">104</span><br><span class="line">105</span><br><span class="line">106</span><br><span class="line">107</span><br><span class="line">108</span><br><span class="line">109</span><br><span class="line">110</span><br><span class="line">111</span><br><span class="line">112</span><br><span class="line">113</span><br><span class="line">114</span><br><span class="line">115</span><br><span class="line">116</span><br><span class="line">117</span><br><span class="line">118</span><br><span class="line">119</span><br><span class="line">120</span><br><span class="line">121</span><br><span class="line">122</span><br><span class="line">123</span><br><span class="line">124</span><br><span class="line">125</span><br><span class="line">126</span><br><span class="line">127</span><br><span class="line">128</span><br><span class="line">129</span><br><span class="line">130</span><br><span class="line">131</span><br><span class="line">132</span><br><span class="line">133</span><br><span class="line">134</span><br><span class="line">135</span><br><span class="line">136</span><br><span class="line">137</span><br><span class="line">138</span><br><span class="line">139</span><br><span class="line">140</span><br><span class="line">141</span><br><span class="line">142</span><br><span class="line">143</span><br><span class="line">144</span><br><span class="line">145</span><br><span class="line">146</span><br><span class="line">147</span><br><span class="line">148</span><br><span class="line">149</span><br><span class="line">150</span><br><span class="line">151</span><br><span class="line">152</span><br><span class="line">153</span><br><span class="line">154</span><br><span class="line">155</span><br><span class="line">156</span><br><span class="line">157</span><br><span class="line">158</span><br><span class="line">159</span><br><span class="line">160</span><br><span class="line">161</span><br><span class="line">162</span><br><span class="line">163</span><br><span class="line">164</span><br><span class="line">165</span><br><span class="line">166</span><br><span class="line">167</span><br><span class="line">168</span><br><span class="line">169</span><br><span class="line">170</span><br><span class="line">171</span><br><span class="line">172</span><br><span class="line">173</span><br><span class="line">174</span><br><span class="line">175</span><br><span class="line">176</span><br><span class="line">177</span><br><span class="line">178</span><br><span class="line">179</span><br><span class="line">180</span><br><span class="line">181</span><br><span class="line">182</span><br><span class="line">183</span><br><span class="line">184</span><br><span class="line">185</span><br><span class="line">186</span><br><span class="line">187</span><br><span class="line">188</span><br><span class="line">189</span><br><span class="line">190</span><br><span class="line">191</span><br><span class="line">192</span><br><span class="line">193</span><br><span class="line">194</span><br><span class="line">195</span><br><span class="line">196</span><br><span class="line">197</span><br><span class="line">198</span><br><span class="line">199</span><br><span class="line">200</span><br><span class="line">201</span><br><span class="line">202</span><br><span class="line">203</span><br><span class="line">204</span><br><span class="line">205</span><br><span class="line">206</span><br><span class="line">207</span><br><span class="line">208</span><br><span class="line">209</span><br><span class="line">210</span><br><span class="line">211</span><br><span class="line">212</span><br><span class="line">213</span><br><span class="line">214</span><br><span class="line">215</span><br><span class="line">216</span><br><span class="line">217</span><br><span class="line">218</span><br><span class="line">219</span><br><span class="line">220</span><br><span class="line">221</span><br><span class="line">222</span><br><span class="line">223</span><br><span class="line">224</span><br><span class="line">225</span><br><span class="line">226</span><br><span class="line">227</span><br><span class="line">228</span><br><span class="line">229</span><br><span class="line">230</span><br><span class="line">231</span><br><span class="line">232</span><br><span class="line">233</span><br><span class="line">234</span><br><span class="line">235</span><br><span class="line">236</span><br><span class="line">237</span><br><span class="line">238</span><br><span class="line">239</span><br><span class="line">240</span><br><span class="line">241</span><br><span class="line">242</span><br><span class="line">243</span><br><span class="line">244</span><br><span class="line">245</span><br><span class="line">246</span><br><span class="line">247</span><br><span class="line">248</span><br><span class="line">249</span><br><span class="line">250</span><br><span class="line">251</span><br><span class="line">252</span><br><span class="line">253</span><br><span class="line">254</span><br><span class="line">255</span><br><span class="line">256</span><br><span class="line">257</span><br><span class="line">258</span><br><span class="line">259</span><br><span class="line">260</span><br><span class="line">261</span><br><span class="line">262</span><br><span class="line">263</span><br><span class="line">264</span><br><span class="line">265</span><br><span class="line">266</span><br><span class="line">267</span><br><span class="line">268</span><br><span class="line">269</span><br><span class="line">270</span><br><span class="line">271</span><br><span class="line">272</span><br><span class="line">273</span><br><span class="line">274</span><br><span class="line">275</span><br><span class="line">276</span><br><span class="line">277</span><br><span class="line">278</span><br><span class="line">279</span><br><span class="line">280</span><br><span class="line">281</span><br><span class="line">282</span><br><span class="line">283</span><br><span class="line">284</span><br><span class="line">285</span><br><span class="line">286</span><br><span class="line">287</span><br><span class="line">288</span><br><span class="line">289</span><br><span class="line">290</span><br><span class="line">291</span><br><span class="line">292</span><br><span class="line">293</span><br><span class="line">294</span><br><span class="line">295</span><br><span class="line">296</span><br><span class="line">297</span><br><span class="line">298</span><br><span class="line">299</span><br><span class="line">300</span><br><span class="line">301</span><br><span class="line">302</span><br><span class="line">303</span><br><span class="line">304</span><br><span class="line">305</span><br><span class="line">306</span><br><span class="line">307</span><br><span class="line">308</span><br><span class="line">309</span><br><span class="line">310</span><br><span class="line">311</span><br><span class="line">312</span><br><span class="line">313</span><br><span class="line">314</span><br><span class="line">315</span><br><span class="line">316</span><br><span class="line">317</span><br><span class="line">318</span><br><span class="line">319</span><br><span class="line">320</span><br><span class="line">321</span><br><span class="line">322</span><br><span class="line">323</span><br><span class="line">324</span><br><span class="line">325</span><br><span class="line">326</span><br><span class="line">327</span><br><span class="line">328</span><br><span class="line">329</span><br><span class="line">330</span><br><span class="line">331</span><br><span class="line">332</span><br><span class="line">333</span><br><span class="line">334</span><br><span class="line">335</span><br><span class="line">336</span><br><span class="line">337</span><br><span class="line">338</span><br><span class="line">339</span><br><span class="line">340</span><br><span class="line">341</span><br><span class="line">342</span><br><span class="line">343</span><br><span class="line">344</span><br><span class="line">345</span><br><span class="line">346</span><br><span class="line">347</span><br><span class="line">348</span><br><span class="line">349</span><br><span class="line">350</span><br><span class="line">351</span><br><span class="line">352</span><br><span class="line">353</span><br><span class="line">354</span><br><span class="line">355</span><br><span class="line">356</span><br><span class="line">357</span><br><span class="line">358</span><br><span class="line">359</span><br><span class="line">360</span><br><span class="line">361</span><br><span class="line">362</span><br><span class="line">363</span><br><span class="line">364</span><br><span class="line">365</span><br><span class="line">366</span><br><span class="line">367</span><br><span class="line">368</span><br><span class="line">369</span><br><span class="line">370</span><br><span class="line">371</span><br><span class="line">372</span><br><span class="line">373</span><br><span class="line">374</span><br><span class="line">375</span><br><span class="line">376</span><br><span class="line">377</span><br><span class="line">378</span><br><span class="line">379</span><br><span class="line">380</span><br><span class="line">381</span><br><span class="line">382</span><br><span class="line">383</span><br><span class="line">384</span><br><span class="line">385</span><br><span class="line">386</span><br><span class="line">387</span><br><span class="line">388</span><br><span class="line">389</span><br><span class="line">390</span><br><span class="line">391</span><br><span class="line">392</span><br><span class="line">393</span><br><span class="line">394</span><br><span class="line">395</span><br><span class="line">396</span><br><span class="line">397</span><br><span class="line">398</span><br><span class="line">399</span><br><span class="line">400</span><br><span class="line">401</span><br><span class="line">402</span><br><span class="line">403</span><br><span class="line">404</span><br><span class="line">405</span><br><span class="line">406</span><br><span class="line">407</span><br><span class="line">408</span><br><span class="line">409</span><br><span class="line">410</span><br><span class="line">411</span><br><span class="line">412</span><br><span class="line">413</span><br><span class="line">414</span><br><span class="line">415</span><br><span class="line">416</span><br><span class="line">417</span><br><span class="line">418</span><br><span class="line">419</span><br><span class="line">420</span><br><span class="line">421</span><br><span class="line">422</span><br><span class="line">423</span><br><span class="line">424</span><br><span class="line">425</span><br><span class="line">426</span><br><span class="line">427</span><br><span class="line">428</span><br><span class="line">429</span><br><span class="line">430</span><br><span class="line">431</span><br><span class="line">432</span><br><span class="line">433</span><br><span class="line">434</span><br><span class="line">435</span><br><span class="line">436</span><br><span class="line">437</span><br><span class="line">438</span><br><span class="line">439</span><br><span class="line">440</span><br><span class="line">441</span><br><span class="line">442</span><br><span class="line">443</span><br><span class="line">444</span><br><span class="line">445</span><br><span class="line">446</span><br><span class="line">447</span><br><span class="line">448</span><br><span class="line">449</span><br><span class="line">450</span><br><span class="line">451</span><br><span class="line">452</span><br><span class="line">453</span><br><span class="line">454</span><br><span class="line">455</span><br><span class="line">456</span><br></pre></td><td class="code"><pre><span class="line"><span class="meta">#<span class="meta-keyword">include</span><span class="meta-string">&lt;stdio.h&gt;</span></span></span><br><span class="line"><span class="meta">#<span class="meta-keyword">include</span><span class="meta-string">&lt;stdlib.h&gt;</span></span></span><br><span class="line"><span class="meta">#<span class="meta-keyword">include</span><span class="meta-string">&lt;string.h&gt;</span></span></span><br><span class="line"><span class="meta">#<span class="meta-keyword">include</span><span class="meta-string">&lt;malloc.h&gt;</span></span></span><br><span class="line"><span class="meta">#<span class="meta-keyword">define</span> FDF -1</span></span><br><span class="line"><span class="meta">#<span class="meta-keyword">define</span> FFF -2</span></span><br><span class="line"><span class="meta">#<span class="meta-keyword">define</span> MAX1 10<span class="comment">//宏定义，表示数组的大小。</span></span></span><br><span class="line"><span class="meta">#<span class="meta-keyword">define</span> MAX2 32</span></span><br><span class="line"><span class="meta">#<span class="meta-keyword">define</span> LIST_INIT_SIZE  200  <span class="comment">//线性表存储空间的初始容量</span></span></span><br><span class="line"><span class="meta">#<span class="meta-keyword">define</span> LISTINCREMENT   20   <span class="comment">//线性存储空间的分配增量</span></span></span><br><span class="line"></span><br><span class="line"></span><br><span class="line"><span class="keyword">typedef</span> <span class="class"><span class="keyword">struct</span> //结构体定义<span class="title">fab</span>，此结构体包含<span class="title">name</span>，和<span class="title">start</span>两个属性</span></span><br><span class="line"><span class="class">&#123;</span></span><br><span class="line">	<span class="keyword">char</span> name;</span><br><span class="line">	<span class="keyword">int</span>  start;</span><br><span class="line">&#125;fab;</span><br><span class="line">fab a[MAX1];</span><br><span class="line"></span><br><span class="line"><span class="keyword">typedef</span> <span class="class"><span class="keyword">struct</span>//索引表</span></span><br><span class="line"><span class="class">&#123;</span></span><br><span class="line">	<span class="keyword">int</span> order;    <span class="comment">//索引表记录号</span></span><br><span class="line">	<span class="keyword">int</span> block;	  <span class="comment">//物理块号</span></span><br><span class="line">&#125;indextab;</span><br><span class="line"></span><br><span class="line"><span class="keyword">typedef</span> <span class="class"><span class="keyword">struct</span></span></span><br><span class="line"><span class="class">&#123;</span></span><br><span class="line">	<span class="keyword">char</span> filename;  <span class="comment">//文件名</span></span><br><span class="line">	indextab *ind;  <span class="comment">//索引表指针</span></span><br><span class="line">	<span class="keyword">int</span> length;    <span class="comment">//当前长度</span></span><br><span class="line">	<span class="keyword">int</span> listsize;  <span class="comment">//当前分配的初始容量</span></span><br><span class="line">&#125;filetab;</span><br><span class="line"></span><br><span class="line"><span class="keyword">typedef</span> <span class="class"><span class="keyword">struct</span>//文件目录结构体</span></span><br><span class="line"><span class="class">&#123;</span></span><br><span class="line">	filetab *file;  <span class="comment">//文件目录表指针</span></span><br><span class="line">	<span class="keyword">char</span> name[<span class="number">10</span>];  <span class="comment">//用户名</span></span><br><span class="line">	<span class="keyword">int</span>  length;    <span class="comment">//当前长度</span></span><br><span class="line">	<span class="keyword">int</span>  listsize;  <span class="comment">//当前分配的初始容量</span></span><br><span class="line">&#125;usertab;</span><br><span class="line">usertab *newbase;</span><br><span class="line"></span><br><span class="line"><span class="keyword">typedef</span> <span class="class"><span class="keyword">struct</span>//用户表结构体</span></span><br><span class="line"><span class="class">&#123;</span></span><br><span class="line">    usertab *user; <span class="comment">//用户表指针</span></span><br><span class="line">    <span class="keyword">int</span> length;</span><br><span class="line">    <span class="keyword">int</span> listsize;</span><br><span class="line">&#125;Sqlist;</span><br><span class="line">Sqlist s;</span><br><span class="line"></span><br><span class="line"><span class="comment">//以下为全局变量以及各种方法的定义</span></span><br><span class="line"></span><br><span class="line"><span class="keyword">int</span> fat[MAX2];    <span class="comment">//定义fat表项</span></span><br><span class="line"><span class="keyword">int</span> filenum = <span class="number">1</span>;  <span class="comment">//记录文件的个数，文件数随着保存而增加</span></span><br><span class="line"><span class="keyword">int</span> c = <span class="number">0</span>;        <span class="comment">//记录所有用户的数量</span></span><br><span class="line"><span class="keyword">int</span> h ;           <span class="comment">//记录每个用户文件的个数</span></span><br><span class="line"><span class="keyword">int</span> m ;                  <span class="comment">//m存放的是文件的个数</span></span><br><span class="line"><span class="keyword">int</span> count1 = <span class="number">0</span>;       <span class="comment">//记录文件的个数，随着转换索引表而动态改变 //count是数量。</span></span><br><span class="line"><span class="keyword">char</span> savename[<span class="number">10</span>][<span class="number">1</span>];  <span class="comment">//保存用户名</span></span><br><span class="line"><span class="keyword">char</span> cr;               <span class="comment">//记录插入文件的名字</span></span><br><span class="line"></span><br><span class="line"><span class="function"><span class="keyword">void</span> <span class="title">begin</span><span class="params">()</span></span>;<span class="comment">//定义方法。代码直接操作。</span></span><br><span class="line"><span class="function"><span class="keyword">void</span> <span class="title">display</span><span class="params">()</span></span>;</span><br><span class="line"><span class="function"><span class="keyword">void</span> <span class="title">insert</span><span class="params">()</span></span>;</span><br><span class="line"><span class="function"><span class="keyword">void</span> <span class="title">save</span><span class="params">()</span></span>;</span><br><span class="line"><span class="function"><span class="keyword">void</span> <span class="title">change</span><span class="params">(<span class="keyword">char</span> name[])</span></span>;</span><br><span class="line"><span class="function"><span class="keyword">void</span> <span class="title">after</span><span class="params">()</span></span>;</span><br><span class="line"></span><br><span class="line"></span><br><span class="line"><span class="function"><span class="keyword">void</span> <span class="title">display</span><span class="params">()</span><span class="comment">//显示方法</span></span></span><br><span class="line"><span class="function"></span>&#123;</span><br><span class="line">	<span class="keyword">int</span> i = <span class="number">0</span>,n,q;</span><br><span class="line">    <span class="built_in">printf</span>(<span class="string">&quot;此时fat表纪录情况为:\n&quot;</span>);</span><br><span class="line">	<span class="keyword">for</span>(i=<span class="number">0</span>;i&lt;MAX2;i++)</span><br><span class="line">		<span class="built_in">printf</span>(<span class="string">&quot;%d : %d\n&quot;</span>,i,fat[i]);<span class="comment">//此时fat表的初始状态为i=0 fat=0</span></span><br><span class="line">	<span class="built_in">printf</span>(<span class="string">&quot;\n此时文件目录表中的情况为:\n&quot;</span>);</span><br><span class="line">	<span class="built_in">printf</span>(<span class="string">&quot;-------------------------------------------\n&quot;</span>);</span><br><span class="line">	<span class="built_in">printf</span>(<span class="string">&quot;文件名\t\t起始块号\t文件长度\n&quot;</span>);</span><br><span class="line">	<span class="keyword">for</span>(i=<span class="number">0</span>;i&lt;=filenum;i++)<span class="comment">//fulenum是文件个数。初始状态为1</span></span><br><span class="line">	&#123;</span><br><span class="line">		q=<span class="number">0</span>;</span><br><span class="line">		n=a[i].start;<span class="comment">//第一个结构体</span></span><br><span class="line">		<span class="keyword">while</span>(<span class="number">1</span>)</span><br><span class="line">		&#123;</span><br><span class="line">			n = fat[n];</span><br><span class="line">			q++;       <span class="comment">//记录此文件的逻辑记录长度</span></span><br><span class="line">			<span class="keyword">if</span>(n==FFF)</span><br><span class="line">				<span class="keyword">break</span>;</span><br><span class="line">		&#125;</span><br><span class="line">		<span class="built_in">printf</span>(<span class="string">&quot;%4c\t\t%4d\t\t%4d\n&quot;</span>,a[i].name,a[i].start,q);</span><br><span class="line">	&#125;</span><br><span class="line">	<span class="built_in">printf</span>(<span class="string">&quot;-------------------------------------------\n&quot;</span>);</span><br><span class="line">&#125;</span><br><span class="line"></span><br><span class="line"></span><br><span class="line"><span class="function"><span class="keyword">void</span> <span class="title">begin</span><span class="params">()</span></span></span><br><span class="line"><span class="function"></span>&#123;</span><br><span class="line">	<span class="keyword">int</span> i,j = <span class="number">0</span>;</span><br><span class="line">	<span class="built_in">printf</span>(<span class="string">&quot;初始化fat表\n&quot;</span>);</span><br><span class="line">	fat[<span class="number">0</span>] = FDF;<span class="comment">//宏定义FDF=-1</span></span><br><span class="line">	fat[<span class="number">1</span>] = FFF;<span class="comment">//宏定义FFF=-2</span></span><br><span class="line">	<span class="keyword">for</span>(i=<span class="number">2</span>;i&lt;MAX2;i++)</span><br><span class="line">	    fat[i] = <span class="number">0</span>;</span><br><span class="line"></span><br><span class="line">	a[<span class="number">0</span>].name = <span class="string">&#x27;A&#x27;</span>;</span><br><span class="line">	a[<span class="number">0</span>].start = <span class="number">2</span>;</span><br><span class="line">	fat[a[<span class="number">0</span>].start] = <span class="number">5</span>;     <span class="comment">//初始化第一个文件</span></span><br><span class="line">	fat[<span class="number">5</span>] = <span class="number">8</span>;</span><br><span class="line">	fat[<span class="number">8</span>] = <span class="number">11</span>;</span><br><span class="line">	fat[<span class="number">11</span>] = <span class="number">18</span>;</span><br><span class="line">	fat[<span class="number">18</span>] = <span class="number">24</span>;</span><br><span class="line">	fat[<span class="number">24</span>] = FFF;</span><br><span class="line"></span><br><span class="line">   	a[<span class="number">1</span>].name = <span class="string">&#x27;B&#x27;</span>;         <span class="comment">//初始化第二个文件</span></span><br><span class="line">	a[<span class="number">1</span>].start = <span class="number">6</span>;</span><br><span class="line">	fat[a[<span class="number">1</span>].start] = <span class="number">9</span>;</span><br><span class="line">	fat[<span class="number">9</span>] = <span class="number">14</span>;</span><br><span class="line">	fat[<span class="number">14</span>] = <span class="number">19</span>;</span><br><span class="line">	fat[<span class="number">19</span>] = <span class="number">22</span>;</span><br><span class="line">	fat[<span class="number">22</span>] = <span class="number">28</span>;</span><br><span class="line">	fat[<span class="number">28</span>] = <span class="number">30</span>;</span><br><span class="line">	fat[<span class="number">30</span>] = FFF;</span><br><span class="line">	display();</span><br><span class="line">	s.user = (usertab *)<span class="built_in">malloc</span>(LIST_INIT_SIZE*<span class="keyword">sizeof</span>(usertab));  <span class="comment">//为用户分配空间</span></span><br><span class="line">    <span class="keyword">if</span>(!s.user)</span><br><span class="line">		<span class="built_in">exit</span>(<span class="number">-2</span>);</span><br><span class="line">    s.length = <span class="number">0</span>;</span><br><span class="line">    s.listsize = LIST_INIT_SIZE;</span><br><span class="line">&#125;</span><br><span class="line"></span><br><span class="line"><span class="function"><span class="keyword">void</span> <span class="title">insert</span><span class="params">()</span></span></span><br><span class="line"><span class="function"></span>&#123;</span><br><span class="line">	<span class="keyword">int</span> k,j,start1,s,n,q,w;</span><br><span class="line">	<span class="keyword">int</span> i=<span class="number">0</span>,p=<span class="number">0</span>;</span><br><span class="line">	<span class="keyword">char</span> iname,jname;</span><br><span class="line">	<span class="built_in">printf</span>(<span class="string">&quot;请输入你要插入的文件名\n&quot;</span>);</span><br><span class="line">	fflush(<span class="built_in">stdin</span>);<span class="comment">//重写操作</span></span><br><span class="line">	<span class="built_in">scanf</span>(<span class="string">&quot;%c&quot;</span>,&amp;iname);</span><br><span class="line">	<span class="keyword">for</span>(i=<span class="number">0</span>;i&lt;MAX1;i++)   <span class="comment">//在文件目录表中找到此文件</span></span><br><span class="line">	&#123;</span><br><span class="line">		<span class="keyword">if</span>(a[i].name!=iname)</span><br><span class="line">		&#123;</span><br><span class="line">			q = i;        <span class="comment">//记录是第几个文件</span></span><br><span class="line">			<span class="keyword">continue</span>;</span><br><span class="line">		&#125;</span><br><span class="line">		<span class="keyword">else</span></span><br><span class="line">		&#123;</span><br><span class="line">			jname = a[i].name;</span><br><span class="line">			cr = iname;     <span class="comment">//记录插入文件的名字</span></span><br><span class="line">			<span class="built_in">printf</span>(<span class="string">&quot;存在此文件!\n&quot;</span>);</span><br><span class="line">			n = a[i].start;<span class="comment">//初始化文件</span></span><br><span class="line">			<span class="keyword">while</span>(<span class="number">1</span>)</span><br><span class="line">			&#123;</span><br><span class="line">				n = fat[n];</span><br><span class="line">				p++;       <span class="comment">//记录此文件的逻辑记录长度</span></span><br><span class="line">				<span class="keyword">if</span>(n==FFF)</span><br><span class="line">					<span class="keyword">break</span>;</span><br><span class="line">			&#125;</span><br><span class="line">			<span class="built_in">printf</span>(<span class="string">&quot;此文件的记录长度为:%d\n&quot;</span>,p);</span><br><span class="line">			<span class="keyword">while</span>(<span class="number">1</span>)</span><br><span class="line">			&#123;</span><br><span class="line">                 <span class="built_in">printf</span>(<span class="string">&quot;请在此1--%d范围内输入你要插入的记录号\n&quot;</span>,p);</span><br><span class="line">			     <span class="built_in">scanf</span>(<span class="string">&quot;%d&quot;</span>,&amp;k);</span><br><span class="line">			     fflush(<span class="built_in">stdin</span>);</span><br><span class="line">			     <span class="keyword">if</span>(k&lt;=<span class="number">0</span>||k&gt;p)</span><br><span class="line">				 &#123;</span><br><span class="line">			    	<span class="built_in">printf</span>(<span class="string">&quot;记录号错误重新输入\n&quot;</span>);</span><br><span class="line">					<span class="keyword">continue</span>;</span><br><span class="line">				 &#125;</span><br><span class="line">				 <span class="keyword">else</span> <span class="keyword">break</span>;</span><br><span class="line">			&#125;</span><br><span class="line">			<span class="keyword">for</span>(i=<span class="number">0</span>;i&lt;MAX2;i++)    <span class="comment">//查找第一个空闲块号</span></span><br><span class="line">			&#123;</span><br><span class="line">				<span class="keyword">if</span>(fat[i]!=<span class="number">0</span>)</span><br><span class="line">				&#123;</span><br><span class="line">					w = i;</span><br><span class="line">					<span class="keyword">continue</span>;</span><br><span class="line">				&#125;</span><br><span class="line">				<span class="keyword">else</span></span><br><span class="line">				&#123;</span><br><span class="line">					<span class="built_in">printf</span>(<span class="string">&quot;有空闲块%d\n&quot;</span>,i);</span><br><span class="line">					j = i;     <span class="comment">//j为空闲块号</span></span><br><span class="line">					<span class="built_in">printf</span>(<span class="string">&quot;逻辑纪录号对应的物理块号为:&quot;</span>);</span><br><span class="line">					<span class="keyword">for</span>(i=<span class="number">0</span>;i&lt;MAX1;i++)    <span class="comment">//查找此文件第一个物理块号</span></span><br><span class="line">					&#123;</span><br><span class="line">						<span class="keyword">if</span>(iname==a[i].name)</span><br><span class="line">						&#123;</span><br><span class="line">							start1=a[i].start;</span><br><span class="line">							<span class="keyword">break</span>;</span><br><span class="line">						&#125;</span><br><span class="line">					&#125;</span><br><span class="line">					<span class="keyword">for</span>(i=<span class="number">0</span>;i&lt;k<span class="number">-1</span>;i++)    <span class="comment">//查找逻辑块号对应的物理块号</span></span><br><span class="line">					&#123;</span><br><span class="line">						m = fat[start1];</span><br><span class="line">						start1 = m;</span><br><span class="line">					&#125;</span><br><span class="line">					<span class="built_in">printf</span>(<span class="string">&quot;%d\n&quot;</span>,start1);</span><br><span class="line">					s = fat[start1];    <span class="comment">//插入纪录</span></span><br><span class="line">					fat[start1] = j;</span><br><span class="line">					fat[j] = s;</span><br><span class="line">					<span class="keyword">break</span>;</span><br><span class="line">				&#125;</span><br><span class="line">				<span class="keyword">if</span>(w==MAX2<span class="number">-1</span>&amp;&amp;fat[w]!=<span class="number">0</span>)</span><br><span class="line">				&#123;</span><br><span class="line">					<span class="built_in">printf</span>(<span class="string">&quot;无空闲块结束\n&quot;</span>);</span><br><span class="line">					<span class="keyword">break</span>;</span><br><span class="line">				&#125;</span><br><span class="line">			&#125;</span><br><span class="line">		&#125;</span><br><span class="line">		<span class="keyword">break</span>;</span><br><span class="line">	&#125;</span><br><span class="line">	<span class="keyword">if</span>(q==MAX1<span class="number">-1</span>&amp;&amp;jname!=iname)</span><br><span class="line">		<span class="built_in">printf</span>(<span class="string">&quot;不存在此文件,结束\n&quot;</span>);</span><br><span class="line">&#125;</span><br><span class="line"></span><br><span class="line"><span class="function"><span class="keyword">void</span> <span class="title">save</span><span class="params">()</span></span></span><br><span class="line"><span class="function"></span>&#123;</span><br><span class="line">	<span class="keyword">char</span> name1;</span><br><span class="line">	<span class="keyword">int</span> num1,i,count=<span class="number">0</span>;</span><br><span class="line">	<span class="keyword">int</span> b[MAX2];    <span class="comment">//数组b中存放空闲区物理块号</span></span><br><span class="line">	<span class="built_in">printf</span>(<span class="string">&quot;请输入要保存文件的信息:文件名和长度\n&quot;</span>);</span><br><span class="line">    fflush(<span class="built_in">stdin</span>);</span><br><span class="line">	<span class="built_in">scanf</span>(<span class="string">&quot;%c %d&quot;</span>,&amp;name1,&amp;num1);</span><br><span class="line">	fflush(<span class="built_in">stdin</span>);</span><br><span class="line">	filenum++;</span><br><span class="line">	m=filenum;   <span class="comment">//m存放的是文件的个数</span></span><br><span class="line">	<span class="keyword">for</span>(i=<span class="number">0</span>;i&lt;MAX1;i++)</span><br><span class="line">	&#123;</span><br><span class="line">		<span class="keyword">if</span>(name1==a[i].name)</span><br><span class="line">		&#123;</span><br><span class="line">			<span class="built_in">printf</span>(<span class="string">&quot;有同名文件!\n&quot;</span>);</span><br><span class="line">			<span class="keyword">return</span>;</span><br><span class="line">		&#125;</span><br><span class="line">	&#125;</span><br><span class="line">	<span class="built_in">printf</span>(<span class="string">&quot;无同名文件,可以保存!\n&quot;</span>);</span><br><span class="line">    <span class="keyword">for</span>(i=<span class="number">0</span>;i&lt;MAX2;i++)</span><br><span class="line">	&#123;</span><br><span class="line">		<span class="keyword">if</span>(fat[i]==<span class="number">0</span>)</span><br><span class="line">		&#123;</span><br><span class="line">			b[count] = i;</span><br><span class="line">			count++;</span><br><span class="line">		&#125;</span><br><span class="line">	&#125;</span><br><span class="line">	<span class="keyword">if</span>(count&lt;num1)</span><br><span class="line">	&#123;</span><br><span class="line">		<span class="built_in">printf</span>(<span class="string">&quot;磁盘空间不够!\n&quot;</span>);</span><br><span class="line">		<span class="keyword">return</span>;</span><br><span class="line">	&#125;</span><br><span class="line">    a[filenum].name = name1;</span><br><span class="line">    a[filenum].start = b[<span class="number">0</span>];</span><br><span class="line">    <span class="built_in">printf</span>(<span class="string">&quot;已将文件存入物理块中\n&quot;</span>);</span><br><span class="line">    <span class="keyword">for</span>(i=<span class="number">0</span>;i&lt;num1<span class="number">-1</span>;i++)</span><br><span class="line">		fat[b[i]] = b[i+<span class="number">1</span>];</span><br><span class="line">	fat[b[i]] = FFF;</span><br><span class="line">&#125;</span><br><span class="line"></span><br><span class="line"><span class="function"><span class="keyword">void</span> <span class="title">change</span><span class="params">(<span class="keyword">char</span> name[])</span></span></span><br><span class="line"><span class="function"></span>&#123;</span><br><span class="line">	<span class="keyword">int</span> j=<span class="number">0</span>;    <span class="comment">//记录当前用户文件的个数</span></span><br><span class="line">	<span class="keyword">int</span> k,n,i;</span><br><span class="line">	<span class="keyword">int</span> flag;</span><br><span class="line">	<span class="keyword">char</span> fname;</span><br><span class="line">	<span class="keyword">if</span>(s.length&gt;=s.listsize)<span class="comment">//listsize为分配的初始容量</span></span><br><span class="line">	&#123;</span><br><span class="line">		newbase = (usertab *)<span class="built_in">realloc</span>(s.user,(s.listsize+LISTINCREMENT)*<span class="keyword">sizeof</span><span class="comment">//为用户分配储存空间，realloc隶属于malloc头文件</span></span><br><span class="line"></span><br><span class="line">(usertab));</span><br><span class="line">		<span class="keyword">if</span>(!newbase)</span><br><span class="line">			<span class="built_in">exit</span>(<span class="number">-2</span>);</span><br><span class="line">		s.user = newbase;</span><br><span class="line">		s.length+=LISTINCREMENT;<span class="comment">//线性储存空间分配增量</span></span><br><span class="line">	&#125;</span><br><span class="line">    <span class="keyword">for</span>(i=<span class="number">0</span>;i&lt;<span class="number">10</span>;i++)           <span class="comment">//将用户名记录到用户表中</span></span><br><span class="line">        s.user[c].name[i] = name[i];</span><br><span class="line">    <span class="built_in">printf</span>(<span class="string">&quot;用户的名字:%s\n&quot;</span>,s.user[c].name);</span><br><span class="line">    s.user[c].file = (filetab *)<span class="built_in">malloc</span>(LIST_INIT_SIZE*<span class="keyword">sizeof</span>(filetab));  <span class="comment">//为文件目录表分配空间</span></span><br><span class="line"></span><br><span class="line">    <span class="keyword">if</span>(!s.user[c].file)</span><br><span class="line">		<span class="built_in">exit</span>(<span class="number">-2</span>);</span><br><span class="line">    s.user[c].length = <span class="number">0</span>;</span><br><span class="line">    s.length++;               <span class="comment">//用户个数加一</span></span><br><span class="line">    s.user[c].listsize = LIST_INIT_SIZE;</span><br><span class="line">	<span class="keyword">while</span>(<span class="number">1</span>)</span><br><span class="line">	&#123;</span><br><span class="line">        <span class="keyword">if</span>(s.user[c].length&gt;=s.user[c].listsize)  <span class="comment">//分配空间</span></span><br><span class="line">		&#123;</span><br><span class="line">			newbase-&gt;file = (filetab *)<span class="built_in">realloc</span>(s.user[c].file,(s.user</span><br><span class="line"></span><br><span class="line">[c].listsize+LISTINCREMENT)*<span class="keyword">sizeof</span>(filetab));</span><br><span class="line">			<span class="keyword">if</span>(!newbase-&gt;file)</span><br><span class="line">				<span class="built_in">exit</span>(<span class="number">-2</span>);</span><br><span class="line">			s.user[c].file = newbase-&gt;file;</span><br><span class="line">			s.user[c].length+=LISTINCREMENT;<span class="comment">//线性储存空间分配增量</span></span><br><span class="line">		&#125;</span><br><span class="line">	repeat:</span><br><span class="line">        fflush(<span class="built_in">stdin</span>);</span><br><span class="line">		<span class="built_in">printf</span>(<span class="string">&quot;请输入此用户的文件名\n&quot;</span>);</span><br><span class="line">		fflush(<span class="built_in">stdin</span>);</span><br><span class="line">		<span class="built_in">scanf</span>(<span class="string">&quot;%c&quot;</span>,&amp;fname);</span><br><span class="line">		fflush(<span class="built_in">stdin</span>);</span><br><span class="line">        <span class="keyword">for</span>(i=<span class="number">0</span>;i&lt;=m;i++)  <span class="comment">//查找此文件是否被其他用户占有</span></span><br><span class="line">		&#123;</span><br><span class="line">			<span class="keyword">if</span>(fname==savename[i][<span class="number">1</span>])</span><br><span class="line">			&#123;</span><br><span class="line">				<span class="built_in">printf</span>(<span class="string">&quot;此文件已经被别的用户占用请重新输入\n&quot;</span>);</span><br><span class="line">				<span class="keyword">goto</span> repeat;</span><br><span class="line">			&#125;</span><br><span class="line">		&#125;</span><br><span class="line">		<span class="keyword">for</span>(i=<span class="number">0</span>;i&lt;MAX1;i++)</span><br><span class="line">		&#123;</span><br><span class="line">			<span class="keyword">if</span>(fname==a[i].name)</span><br><span class="line">			&#123;</span><br><span class="line">                h=i;  <span class="comment">//h记录用户的文件</span></span><br><span class="line">				<span class="keyword">break</span>;</span><br><span class="line">			&#125;</span><br><span class="line">			<span class="keyword">else</span> <span class="keyword">if</span>(i==MAX1<span class="number">-1</span>)</span><br><span class="line">			&#123;</span><br><span class="line">				<span class="built_in">printf</span>(<span class="string">&quot;不存在此文件重新输入\n&quot;</span>);</span><br><span class="line">				<span class="keyword">goto</span> repeat;</span><br><span class="line">			&#125;</span><br><span class="line">		&#125;</span><br><span class="line">		savename[h][<span class="number">1</span>] = fname;</span><br><span class="line">		count1++;      <span class="comment">//索引表中文件加一</span></span><br><span class="line">		s.user[c].file[j].filename = fname;</span><br><span class="line">		s.user[c].file[j].ind = (indextab *)<span class="built_in">malloc</span>(LIST_INIT_SIZE*<span class="keyword">sizeof</span>(indextab)); <span class="comment">//为文件索引表分配空间</span></span><br><span class="line">		<span class="keyword">if</span> (!s.user[c].file[j].ind)</span><br><span class="line">			<span class="built_in">exit</span>(<span class="number">-2</span>);</span><br><span class="line">		s.user[c].file[j].length=<span class="number">0</span>;</span><br><span class="line">		s.user[c].length++;   <span class="comment">//用户文件长度加一</span></span><br><span class="line">		s.user[c].file[j].listsize = LIST_INIT_SIZE;</span><br><span class="line">		n = a[h].start;</span><br><span class="line">        <span class="keyword">for</span>(k=<span class="number">0</span>;;k++)</span><br><span class="line">		&#123;</span><br><span class="line">			<span class="keyword">if</span>(s.user[c].file[j].length&gt;=s.user[c].file[j].listsize)</span><br><span class="line">			&#123;</span><br><span class="line">				newbase-&gt;file[j].ind = (indextab *)<span class="built_in">realloc</span>(s.user[c].file[j].ind,(s.user[c].file[j].listsize+LISTINCREMENT)*<span class="keyword">sizeof</span>(indextab));</span><br><span class="line">				<span class="keyword">if</span>(!newbase-&gt;file[j].ind)</span><br><span class="line">					<span class="built_in">exit</span>(<span class="number">-2</span>);</span><br><span class="line">				s.user[c].file[j].ind = newbase-&gt;file[j].ind;</span><br><span class="line">				s.user[c].file[j].length+=LISTINCREMENT;</span><br><span class="line">			&#125;</span><br><span class="line">			s.user[c].file[j].ind[k].order = k+<span class="number">1</span>;<span class="comment">//索引表记录号</span></span><br><span class="line">			s.user[c].file[j].ind[k].block = n;<span class="comment">//物理模块号</span></span><br><span class="line">			n = fat[n];</span><br><span class="line">			s.user[c].file[j].length++;</span><br><span class="line">			<span class="keyword">if</span>(n==<span class="number">-2</span>) <span class="comment">//FFF=-2</span></span><br><span class="line">				<span class="keyword">break</span>;</span><br><span class="line">		&#125;</span><br><span class="line">		j++;</span><br><span class="line">		c++;<span class="comment">//</span></span><br><span class="line">        <span class="keyword">if</span>(count1<span class="number">-1</span>==filenum)</span><br><span class="line">		&#123;</span><br><span class="line">			<span class="built_in">printf</span>(<span class="string">&quot;fat表转换完毕!\n&quot;</span>);</span><br><span class="line">			<span class="keyword">return</span>;</span><br><span class="line">		&#125;</span><br><span class="line">		<span class="keyword">while</span>(<span class="number">1</span>)</span><br><span class="line">		&#123;</span><br><span class="line">			<span class="built_in">printf</span>(<span class="string">&quot;此用户是否还有另外的文件？如果有文件输入1，否则输入0\n&quot;</span>);</span><br><span class="line">			fflush(<span class="built_in">stdin</span>);</span><br><span class="line">			<span class="built_in">scanf</span>(<span class="string">&quot;%d&quot;</span>,&amp;flag);</span><br><span class="line">			fflush(<span class="built_in">stdin</span>);</span><br><span class="line">			<span class="keyword">if</span>(flag==<span class="number">1</span>)</span><br><span class="line">			&#123;</span><br><span class="line">				c--;</span><br><span class="line">				<span class="keyword">break</span>;</span><br><span class="line">			&#125;</span><br><span class="line">			<span class="keyword">else</span> <span class="keyword">if</span>(flag!=<span class="number">0</span>)</span><br><span class="line">			&#123;</span><br><span class="line">				<span class="built_in">printf</span>(<span class="string">&quot;输入错误,重新输入\n&quot;</span>);</span><br><span class="line">				<span class="keyword">continue</span>;</span><br><span class="line">			&#125;</span><br><span class="line">			<span class="keyword">else</span></span><br><span class="line">				<span class="keyword">break</span>;</span><br><span class="line">		&#125;</span><br><span class="line">		<span class="keyword">if</span>(flag==<span class="number">0</span>)</span><br><span class="line">			<span class="keyword">break</span>;</span><br><span class="line">	&#125;</span><br><span class="line">&#125;</span><br><span class="line"></span><br><span class="line"><span class="function"><span class="keyword">void</span> <span class="title">after</span><span class="params">()</span></span></span><br><span class="line"><span class="function"></span>&#123;</span><br><span class="line">	<span class="keyword">int</span> i,j,k;</span><br><span class="line">	<span class="built_in">printf</span>(<span class="string">&quot;**********************************\n&quot;</span>);</span><br><span class="line">	fflush(<span class="built_in">stdin</span>);</span><br><span class="line">	<span class="keyword">for</span>(k=<span class="number">0</span>;k&lt;c;k++)</span><br><span class="line">	&#123;</span><br><span class="line">		fflush(<span class="built_in">stdin</span>);<span class="comment">//重写操作。目的是清除缓存。</span></span><br><span class="line">		<span class="built_in">printf</span>(<span class="string">&quot;用户%s的索引表为:\n&quot;</span>,s.user[k].name);</span><br><span class="line">		fflush(<span class="built_in">stdin</span>);</span><br><span class="line">		<span class="keyword">for</span>(i=<span class="number">0</span>;i&lt;s.user[k].length;i++)</span><br><span class="line">		&#123;</span><br><span class="line">			<span class="built_in">printf</span>(<span class="string">&quot;文件名:%c\n&quot;</span>,s.user[k].file[i].filename);</span><br><span class="line">			<span class="built_in">printf</span>(<span class="string">&quot;记录号:\t物理块号:\n&quot;</span>);</span><br><span class="line">			<span class="keyword">for</span>(j=<span class="number">0</span>;j&lt;s.user[k].file[i].length;j++)</span><br><span class="line">				<span class="built_in">printf</span>(<span class="string">&quot;%4d\t%4d\n&quot;</span>,s.user[k].file[i].ind[j].order,s.user[k].file[i].ind[j].block);</span><br><span class="line">		&#125;</span><br><span class="line">	&#125;</span><br><span class="line">&#125;</span><br><span class="line"></span><br><span class="line"></span><br><span class="line"><span class="function"><span class="keyword">int</span> <span class="title">main</span><span class="params">()</span></span></span><br><span class="line"><span class="function"></span>&#123;</span><br><span class="line">	<span class="keyword">char</span> name[<span class="number">10</span>];</span><br><span class="line">	<span class="keyword">int</span> x,i;</span><br><span class="line">	<span class="keyword">while</span>(<span class="number">1</span>)</span><br><span class="line">	&#123;</span><br><span class="line">	    <span class="keyword">for</span>(i=<span class="number">0</span>;i&lt;<span class="number">10</span>;i++)</span><br><span class="line">       		 savename[i][<span class="number">1</span>] =<span class="string">&#x27;\0&#x27;</span>;</span><br><span class="line">	    <span class="built_in">printf</span>(<span class="string">&quot;***************************************************************\n&quot;</span>);</span><br><span class="line">		<span class="built_in">printf</span>(<span class="string">&quot;\n\t模拟设计MS-DOS操作系统中磁盘文件的索引文件结构\n&quot;</span>);</span><br><span class="line">		<span class="built_in">printf</span>(<span class="string">&quot;\n\t\t选择1: 初始化fat&quot;</span>);</span><br><span class="line">		<span class="built_in">printf</span>(<span class="string">&quot;\n\t\t选择2: 显示fat表&quot;</span>);</span><br><span class="line">	    <span class="built_in">printf</span>(<span class="string">&quot;\n\t\t选择3: 插入逻辑记录号操作&quot;</span>);</span><br><span class="line">        <span class="built_in">printf</span>(<span class="string">&quot;\n\t\t选择4: 保存文件操作&quot;</span>);</span><br><span class="line">		<span class="built_in">printf</span>(<span class="string">&quot;\n\t\t选择5: 转换索引表&quot;</span>);</span><br><span class="line">		<span class="built_in">printf</span>(<span class="string">&quot;\n\t\t选择6: 显示转换后的索引表&quot;</span>);</span><br><span class="line">		<span class="built_in">printf</span>(<span class="string">&quot;\n\t\t选择0: 结束&quot;</span>);</span><br><span class="line">		<span class="built_in">printf</span></span><br><span class="line"></span><br><span class="line">(<span class="string">&quot;\n\n***************************************************************\n&quot;</span>);</span><br><span class="line">		<span class="built_in">printf</span>(<span class="string">&quot;请输入选择的操作:&quot;</span>);</span><br><span class="line">		<span class="built_in">scanf</span>(<span class="string">&quot;%d&quot;</span>,&amp;x);</span><br><span class="line">		<span class="keyword">switch</span>(x)</span><br><span class="line">		&#123;</span><br><span class="line">			<span class="keyword">case</span> <span class="number">1</span>:begin();</span><br><span class="line">				   <span class="keyword">break</span>;</span><br><span class="line">			<span class="keyword">case</span> <span class="number">2</span>:display();</span><br><span class="line">				   <span class="keyword">break</span>;</span><br><span class="line">			<span class="keyword">case</span> <span class="number">3</span>:insert();</span><br><span class="line">				   <span class="keyword">break</span>;</span><br><span class="line">			<span class="keyword">case</span> <span class="number">4</span>:save();</span><br><span class="line">				   <span class="keyword">break</span>;</span><br><span class="line">			<span class="keyword">case</span> <span class="number">5</span>:<span class="built_in">printf</span>(<span class="string">&quot;\n*********************************************\n&quot;</span>);</span><br><span class="line">                   <span class="keyword">while</span>(count1<span class="number">-1</span>&lt;filenum)    <span class="comment">//在存入索引表的文件小于等于总文件个数的时候</span></span><br><span class="line">				   &#123;</span><br><span class="line">						<span class="built_in">printf</span>(<span class="string">&quot;将fat表转换成索引表\n&quot;</span>);</span><br><span class="line">					    <span class="keyword">while</span>(<span class="number">1</span>)</span><br><span class="line">						&#123;</span><br><span class="line">						    <span class="built_in">printf</span>(<span class="string">&quot;请输入用户名\n&quot;</span>);</span><br><span class="line">                            fflush(<span class="built_in">stdin</span>);</span><br><span class="line">		                    <span class="built_in">scanf</span>(<span class="string">&quot;%s&quot;</span>,name);</span><br><span class="line">		                    change(name);</span><br><span class="line">							<span class="keyword">break</span>;</span><br><span class="line">						&#125;</span><br><span class="line">				   &#125;</span><br><span class="line">			       <span class="keyword">break</span>;</span><br><span class="line">			<span class="keyword">case</span> <span class="number">6</span>:after();</span><br><span class="line">				   <span class="keyword">break</span>;</span><br><span class="line">			<span class="keyword">case</span> <span class="number">0</span>:<span class="keyword">break</span>;</span><br><span class="line">		&#125;</span><br><span class="line">		<span class="keyword">if</span>(x==<span class="number">0</span>) <span class="keyword">break</span>;</span><br><span class="line">	&#125;</span><br><span class="line">    <span class="keyword">return</span> <span class="number">0</span>;</span><br><span class="line">&#125;</span><br><span class="line"></span><br><span class="line"></span><br></pre></td></tr></table></figure>


    </div>
    
    
    

      <footer class="post-footer">
          
          <div class="post-tags">
              <a href="/tags/C/" rel="tag"><i class="fa fa-tag"></i> C++</a>
          </div>

        


        
    <div class="post-nav">
      <div class="post-nav-item">
    <a href="/2021/12/15/os-schoollab-7/" rel="prev" title="LRU算法&&首次适应分配及位图维护内存分配实现">
      <i class="fa fa-chevron-left"></i> LRU算法&&首次适应分配及位图维护内存分配实现
    </a></div>
      <div class="post-nav-item">
    <a href="/2021/12/20/cppadv-typename/" rel="next" title="探究C++语法细节 typename">
      探究C++语法细节 typename <i class="fa fa-chevron-right"></i>
    </a></div>
    </div>
      </footer>
    
  </article>
  
  
  



          </div>
          

<script>
  window.addEventListener('tabs:register', () => {
    let { activeClass } = CONFIG.comments;
    if (CONFIG.comments.storage) {
      activeClass = localStorage.getItem('comments_active') || activeClass;
    }
    if (activeClass) {
      let activeTab = document.querySelector(`a[href="#comment-${activeClass}"]`);
      if (activeTab) {
        activeTab.click();
      }
    }
  });
  if (CONFIG.comments.storage) {
    window.addEventListener('tabs:click', event => {
      if (!event.target.matches('.tabs-comment .tab-content .tab-pane')) return;
      let commentClass = event.target.classList[1];
      localStorage.setItem('comments_active', commentClass);
    });
  }
</script>

        </div>
          
  
  <div class="toggle sidebar-toggle">
    <span class="toggle-line toggle-line-first"></span>
    <span class="toggle-line toggle-line-middle"></span>
    <span class="toggle-line toggle-line-last"></span>
  </div>

  <aside class="sidebar">
    <div class="sidebar-inner">

      <ul class="sidebar-nav motion-element">
        <li class="sidebar-nav-toc">
          文章目录
        </li>
        <li class="sidebar-nav-overview">
          站点概览
        </li>
      </ul>

      <!--noindex-->
      <div class="post-toc-wrap sidebar-panel">
          <div class="post-toc motion-element"><ol class="nav"><li class="nav-item nav-level-2"><a class="nav-link" href="#%E5%AE%9E%E9%AA%8C%E5%86%85%E5%AE%B9"><span class="nav-number">1.</span> <span class="nav-text">实验内容</span></a></li><li class="nav-item nav-level-2"><a class="nav-link" href="#%E5%AE%9E%E9%AA%8C%E9%A2%98%E7%9B%AE"><span class="nav-number">2.</span> <span class="nav-text">实验题目</span></a><ol class="nav-child"><li class="nav-item nav-level-3"><a class="nav-link" href="#1-%E6%A8%A1%E6%8B%9F%E8%AE%BE%E8%AE%A1MS-DOS%E6%93%8D%E4%BD%9C%E7%B3%BB%E7%BB%9F%E4%B8%AD%E7%A3%81%E7%9B%98%E6%96%87%E4%BB%B6%E7%9A%84%E5%AD%98%E5%82%A8%E7%BB%93%E6%9E%84%E3%80%82"><span class="nav-number">2.1.</span> <span class="nav-text">1.模拟设计MS-DOS操作系统中磁盘文件的存储结构。</span></a></li><li class="nav-item nav-level-3"><a class="nav-link" href="#2-%E6%A8%A1%E6%8B%9F%E4%BE%BF%E4%BA%8E%E7%9B%B4%E6%8E%A5%E5%AD%98%E5%8F%96%E7%9A%84%E7%B4%A2%E5%BC%95%E6%96%87%E4%BB%B6%E7%BB%93%E6%9E%84"><span class="nav-number">2.2.</span> <span class="nav-text">2.模拟便于直接存取的索引文件结构</span></a></li></ol></li></ol></div>
      </div>
      <!--/noindex-->

      <div class="site-overview-wrap sidebar-panel">
        <div class="site-author motion-element" itemprop="author" itemscope itemtype="http://schema.org/Person">
    <img class="site-author-image" itemprop="image" alt="Sekla"
      src="/images/avatar.jpg">
  <p class="site-author-name" itemprop="name">Sekla</p>
  <div class="site-description" itemprop="description">Sekla</div>
</div>
<div class="site-state-wrap motion-element">
  <nav class="site-state">
      <div class="site-state-item site-state-posts">
          <a href="/archives/">
        
          <span class="site-state-item-count">100</span>
          <span class="site-state-item-name">日志</span>
        </a>
      </div>
      <div class="site-state-item site-state-categories">
            <a href="/categories/">
          
        <span class="site-state-item-count">23</span>
        <span class="site-state-item-name">分类</span></a>
      </div>
      <div class="site-state-item site-state-tags">
            <a href="/tags/">
          
        <span class="site-state-item-count">14</span>
        <span class="site-state-item-name">标签</span></a>
      </div>
  </nav>
</div>
  <div class="links-of-author motion-element">
      <span class="links-of-author-item">
        <a href="https://github.com/ShenTiao" title="GitHub → https:&#x2F;&#x2F;github.com&#x2F;ShenTiao" rel="noopener" target="_blank"><i class="fab fa-github fa-fw"></i>GitHub</a>
      </span>
      <span class="links-of-author-item">
        <a href="mailto:584892986@qq.com" title="E-Mail → mailto:584892986@qq.com" rel="noopener" target="_blank"><i class="fa fa-envelope fa-fw"></i>E-Mail</a>
      </span>
  </div>



      </div>

      <iframe frameborder="no" border="0" marginwidth="0" marginheight="0" width=330 height=86 src="//music.163.com/outchain/player?type=2&id=1416875904&auto=0&height=66"></iframe>
      
    </div>
  </aside>
  <div id="sidebar-dimmer"></div>


      </div>
    </main>

    <footer class="footer">
      <div class="footer-inner">
        

        

<div class="copyright">
  
  &copy; 
  <span itemprop="copyrightYear">2022</span>
  <span class="with-love">
    <i class="fa fa-heart"></i>
  </span>
  <span class="author" itemprop="copyrightHolder">Sekla</span>
    <span class="post-meta-divider">|</span>
    <span class="post-meta-item-icon">
      <i class="fa fa-chart-area"></i>
    </span>
    <span title="站点总字数">288k</span>
    <span class="post-meta-divider">|</span>
    <span class="post-meta-item-icon">
      <i class="fa fa-coffee"></i>
    </span>
    <span title="站点阅读时长">4:22</span>
</div>
  <div class="powered-by">由 <a href="https://hexo.io/" class="theme-link" rel="noopener" target="_blank">Hexo</a> & <a href="https://muse.theme-next.org/" class="theme-link" rel="noopener" target="_blank">NexT.Muse</a> 强力驱动
  </div>

        
<div class="busuanzi-count">
  <script async src="https://busuanzi.ibruce.info/busuanzi/2.3/busuanzi.pure.mini.js"></script>
    <span class="post-meta-item" id="busuanzi_container_site_uv" style="display: none;">
      <span class="post-meta-item-icon">
        <i class="fa fa-user"></i>
      </span>
      <span class="site-uv" title="总访客量">
        <span id="busuanzi_value_site_uv"></span>
      </span>
    </span>
    <span class="post-meta-divider">|</span>
    <span class="post-meta-item" id="busuanzi_container_site_pv" style="display: none;">
      <span class="post-meta-item-icon">
        <i class="fa fa-eye"></i>
      </span>
      <span class="site-pv" title="总访问量">
        <span id="busuanzi_value_site_pv"></span>
      </span>
    </span>
</div>








      </div>
    </footer>
  </div>

  
  <script size="300" alpha="0.6" zIndex="-1" src="/lib/canvas-ribbon/canvas-ribbon.js"></script>
  <script src="/lib/anime.min.js"></script>
  <script src="/lib/velocity/velocity.min.js"></script>
  <script src="/lib/velocity/velocity.ui.min.js"></script>

<script src="/js/utils.js"></script>

<script src="/js/motion.js"></script>


<script src="/js/schemes/muse.js"></script>


<script src="/js/next-boot.js"></script>




  















  

  
      

<script>
  if (typeof MathJax === 'undefined') {
    window.MathJax = {
      loader: {
        source: {
          '[tex]/amsCd': '[tex]/amscd',
          '[tex]/AMScd': '[tex]/amscd'
        }
      },
      tex: {
        inlineMath: {'[+]': [['$', '$']]},
        tags: 'ams'
      },
      options: {
        renderActions: {
          findScript: [10, doc => {
            document.querySelectorAll('script[type^="math/tex"]').forEach(node => {
              const display = !!node.type.match(/; *mode=display/);
              const math = new doc.options.MathItem(node.textContent, doc.inputJax[0], display);
              const text = document.createTextNode('');
              node.parentNode.replaceChild(text, node);
              math.start = {node: text, delim: '', n: 0};
              math.end = {node: text, delim: '', n: 0};
              doc.math.push(math);
            });
          }, '', false],
          insertedScript: [200, () => {
            document.querySelectorAll('mjx-container').forEach(node => {
              let target = node.parentNode;
              if (target.nodeName.toLowerCase() === 'li') {
                target.parentNode.classList.add('has-jax');
              }
            });
          }, '', false]
        }
      }
    };
    (function () {
      var script = document.createElement('script');
      script.src = '//cdn.jsdelivr.net/npm/mathjax@3/es5/tex-mml-chtml.js';
      script.defer = true;
      document.head.appendChild(script);
    })();
  } else {
    MathJax.startup.document.state(0);
    MathJax.texReset();
    MathJax.typeset();
  }
</script>

    

  

<script src="/live2dw/lib/L2Dwidget.min.js?094cbace49a39548bed64abff5988b05"></script><script>L2Dwidget.init({"pluginRootPath":"live2dw/","pluginJsPath":"lib/","pluginModelPath":"assets/","tagMode":false,"debug":false,"model":{"jsonPath":"/live2dw/assets/shizuku.model.json"},"display":{"position":"left","width":250,"height":500},"mobile":{"show":false},"react":{"opacity":0.9},"log":false});</script></body>
</html>

<script type="text/javascript" src="/js/src/love.js"></script>
